package com.handsome.工厂模式.简单工厂模式.常规写法.order;

import com.handsome.工厂模式.简单工厂模式.常规写法.pizza.CheesePizza;
import com.handsome.工厂模式.简单工厂模式.常规写法.pizza.GreekPizza;
import com.handsome.工厂模式.简单工厂模式.常规写法.pizza.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author niechun
 * @date 2023/1/8 16:12
 */
public class Order {

    public void order() {
        do {
            Pizza pizza=null;
            String orderType = getType();
            if ("greek".equals(orderType)) {
                pizza = new GreekPizza("greek pizza");
            } else if ("cheese".equals(orderType)) {
                pizza = new CheesePizza("cheese pizza");
            } else {
                break;
            }
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        } while (true);


    }

    public String getType() {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String name;
        try {
            name = bufferedReader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return name;
    }
}
